<?php
class ClientController extends Zend_Controller_Action{
	var $url_server = 'http://192.168.73.125/webservice_adroid/webseviceAdroid/public/server';
	
	///////METHOD CLIENT CALL SERVER//////////////////////////////////////////////////////
	/**
	 * Test sevice
	 * @method indexAction
	 */
    public function indexAction()
    {
		$this->service_client('test');
    }
    
    
    /**
     * @method testAction
     * @return  Array
     */
    public function testAction(){
    	$this->service_client('getQuestions');
    }
    //----------------------------------------------------------------------------
    /**
     * @method testSamplate
     * @input $num_record
     * @return Array
     * @call method: $this->sevice_client('questionData',$num_record)
     * @description
     *		Return array with info of question
     */
    public function testSamplateAction(){
    	$this->service_client('questionData',10);
    }
    //----------------------------------------------------------------------------
    /**
     * @method testSeviceAction
     * @input $num_record
     * @return Array
     * @call method: $this->sevice_client('getData',$num_record)
     * @description
     *		Return array with info of question
     */
    
    public  function testSeviceAction(){
    	$this->service_client('getData',10);
    }
    //////////SETUP CLIENT////////////////////////////////////////////////////////////////
    //------------------------------------------------------------------------
    /**
     * @method service_client
     * @param $func
     * @param $arag
     * @return array
     */
	
    public function successAction()
    {
        // action body
    }
    public function init(){
    
    }
    public function service_client($func = null,$arag= NULL){
            $client = new Zend_XmlRpc_Client($this->url_server);//'http://192.168.73.125/webservice_adroid/webseviceAdroid/public/server');
        try {
        	if(!isset($arag))
        		$data = $client->call('cf.'.$func);    
        	else 
        		$data = $client->call('cf.'.$func,$arag);        	
        	$this->view->data = $data;
        } catch (Zend_XmlRpc_Client_HttpException $e) {
        	require_once 'Zend/Exception.php';
        	throw new Zend_Exception($e);
		} catch (Zend_XmlRpc_Client_FaultException $e) {
 			require_once 'Zend/Exception.php';
        	throw new Zend_Exception($e);
		}
    }
}